import { Comm } from "../utils/common.js";
class Comment extends Comm {
    constructor() {
        super();

        this.getCommentsData = {
            postId: 0,
            Page: 1,
            PageSize: 10
        }
    };
    /**
     * 评论帖子
     */
    comment(options) {
            return new Promise((resolve, reject) => {
                let props = {
                    url: "/gateway/api/post/comment",
                    data: options,
                    sCallBack: res => {
                        resolve(res);
                    },
                    eCallBack: err => {
                        reject(err);
                    }
                }
                this.request(props);
            });
        }
        /**
         * 请求评论列表
         */
    getComments(options) {
            this.getCommentsData.Page = options.type == "first" ? 1 : this.getCommentsData.Page + 1;
            this.getCommentsData.postId = options.postId;
            return new Promise((resolve, reject) => {
                let props = {
                    url: "/gateway/api/comment/list",
                    data: this.getCommentsData,
                    type: "GET",
                    sCallBack: res => {
                        resolve(res);
                    },
                    eCallBack: err => {
                        reject(err);
                    }
                }
                this.request(props);
            });
        }
        /**
         * 评论点赞
         */
    thumb(options) {
            console.log(options);
            const url = options.type == "like" ? "/gateway/api/comment/like" : "/gateway/api/comment/unlike"
            return new Promise((resolve, reject) => {
                let props = {
                    url: url,
                    type: "POST",
                    data: {
                        commentId: options.id
                    },
                    sCallBack: res => {
                        resolve(res);
                    },
                    eCallBack: err => {
                        reject(err);
                    }
                }
                this.request(props);
            })
        }
        /**
         * 评论回复
         */
    reply(options) {
            return new Promise((resolve, reject) => {
                let props = {
                    url: "/gateway/api/comment/reply",
                    data: options,
                    sCallBack: res => {
                        resolve(res);
                    },
                    eCallBack: err => {
                        reject(err);
                    }
                }
                this.request(props);
            });
        }
        /**
         * 评论删除
         */
    delete(id) {
        return new Promise((resolve, reject) => {
            let props = {
                url: "/gateway/api/comment/delete",
                data: {
                    commentId: id
                },
                sCallBack: res => {
                    resolve(res);
                },
                eCallBack: err => {
                    reject(err);
                }
            }
            this.request(props);
        });
    }
}

export { Comment }